from django.db import models
from case.models import case
from django.contrib.auth.models import User
from stock.models import items


class Lab_record(models.Model):
    lab_id = models.CharField(max_length=64, primary_key=True)
    lab_description = models.CharField(max_length=128)
    lab_item = models.ForeignKey(items,on_delete=models.CASCADE,related_name='lab_item')
    lab_operator = models.ForeignKey(User, on_delete=models.CASCADE, related_name='report_lab_operator')
    lab_created_time = models.DateTimeField()
    lab_result = models.FileField(null=True)
    case = models.ForeignKey(case, on_delete=models.CASCADE,related_name="lab_case")

# Create your models here.


class Report(models.Model):
    case = models.ForeignKey(case, on_delete=models.CASCADE, related_name='report_case')
    lab_attendant = models.ForeignKey(User, on_delete=models.CASCADE, related_name='report_lab_attendant')
    generated_date = models.DateField()
    description = models.CharField(max_length=200)

    def __str__(self):
        return self.case

